package com.power.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.power.model.jdao.IZhidingDao;
import com.power.model.mdao.ZhidingMapper;
import com.power.model.pojo.Zhiding;

@Service
public class ZhidingService {
@Autowired
ZhidingMapper mapper;
@Autowired
IZhidingDao dao;
public List<Zhiding> selectAll(int pagenum,int pagesize){//分页查询
	PageHelper.startPage(pagenum, pagesize);
	return mapper.selectAll();
}
//多条件添加
public List<Zhiding> duotiaojian(String rwname, String rwzt, String xfuser, Date xfdate,
		Date wcdate,int pagenum,int pagesize){
	PageHelper.startPage(pagenum, pagesize);
	System.out.println("任务名称:"+rwname+",任务状态:"+rwzt+"，下发人："+xfuser+",下发时间："+xfdate+",完成时间："+wcdate);
	List<Zhiding> list=mapper.duotiaojian( rwname, rwzt, xfuser, xfdate, wcdate);
	System.out.println(list);
	
	return list;
	
}
//添加
public Integer addZhiding(Zhiding zhiding) {
	System.out.println("消缺任务信息添加"+zhiding);
	dao.save(zhiding);
	return zhiding.getRwid();//返回任务编号
	
	
}
//根据编号修改是否取消
public void  updateqx(Integer rwid,Integer qx) {
	dao.updateqx(qx, rwid);

}
//修改
public boolean updateZhiding(Zhiding zhiding) {
	System.out.println("消缺任务信息添加"+zhiding);
	int id = zhiding.getRwid();
	System.out.println("id222"+id);
	Zhiding z=dao.findById(id).get();
	z.setRwid(zhiding.getRwid());
	z.setQx(zhiding.getQx());
	z.setRwname(zhiding.getRwname());
	z.setRwzt(zhiding.getRwzt());
	z.setWcdate(zhiding.getWcdate());
	z.setWorkdj(zhiding.getWorkdj());
	z.setXfdate(zhiding.getXfdate());
	z.setXfuser(zhiding.getXfuser());
	dao.save(zhiding);
	return true;

}
//删除
public void delete(Integer rwid){
	mapper.delete(rwid);
}
}
